import {get,post} from '../../utils/request.js'
const state = {
staffs:[],
total:0
}

const actions = {
findAllStaff(context,list){
    get('/baseUser/pageQuery',list).then(res=>{
        // console.log(res.data.list);
        let response = res.data.list
        let total = res.data.total
        context.commit('SET_STAFF',response)
        context.commit('SET_TOTAL',total)
    })

},
// 保存员工信息
saveStaff(context,list){
    // console.log(list);
   let response  =  post('/baseUser/saveOrUpdate',list)
   return response
  },
   // 删除员工信息
   deleteStaff(context,list){
    let response = get('/baseUser/deleteById',list)
    return response
   }
}

const mutations = {
    SET_STAFF(state,response){
        state.staffs = response
    },
    SET_TOTAL(state,total){
        state.total = total
    }
}

export default{
    namespaced:true,
    state,
    actions,
    mutations
}